// Author: combacsa@kaist.ac.kr
// http://www.jungol.co.kr/prog/Hanal/hanalView.php?qs_code=2556
// Very Easy!

//#define COMPILE_P2556
#ifdef COMPILE_P2556

#include <fstream>

using namespace std;


int main() {
	int a = 0, b = 0, c = 0;
	ifstream in("input.txt");
	in >> a >> b >> c;
	in.close();

	b += c;
	a += b / 60;
	b %= 60;
	a %= 24;

	ofstream out("output.txt");
	out << a << " " << b << "\n";
	out.close();
	return 0;
}

#endif
